
** AGGRESSION, CRIME, AND ANTI-SOCIAL BEHAVIOR **

	// ANTISOCIAL BEHAVIORS (p1_e5m, p3_b, p1_e12m, p1_b, p2_b, p2_e2w, p3_e2w)



/*
		foreach x of varlist   {
			replace `x'=.n if `x'==-999
		}


fightsmlleader2w_e fightsmlpolice2w_e fightsmlneigh2w_e fightsmlleader_e fightsmlpolice_e fightsmlneigh_e stealtakethingsx_e  stealscrapex_e  ///
	     disputes_serious_all_g2_e disputes_serious_all_le1_e disputes_serious_all_g15_e
*/

		foreach p in b e {

			sum asb_reactlose_`p' asb_reacthit_`p' asb_reactdefend_`p' asb_reacttease_`p' asb_proontop_`p' asb_provandalize_`p' asb_procompetitor_`p' asb_prophysforce_`p' asb_procuss_`p'

			* Positive questions: Change to 0-No 1-One one time 2-Sometimes 3-Everytime
				foreach x in asb_reactlose asb_reacthit asb_reactdefend asb_reacttease asb_proontop asb_provandalize asb_procompetitor asb_prophysforce asb_procuss {
					gen `x'_resc_`p' = `x'_`p'*-1+4
						local lab: var lab `x'_`p'
						la var `x'_resc_`p' "Rescaled: `lab'"
				}

			* Analyze responses
				sum asb_reactlose_resc_`p' asb_reacthit_resc_`p' asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_provandalize_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' asb_procuss_resc_`p'
				pwcorr asb_reactlose_resc_`p' asb_reacthit_resc_`p' asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_provandalize_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' asb_procuss_resc_`p'
				factor asb_reactlose_resc_`p' asb_reacthit_resc_`p' asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_provandalize_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' asb_procuss_resc_`p'

			* Generate declared anitsocial behavior index for all
				egen asb_`p' = rowtotal(asb_reactlose_resc_`p' asb_reacthit_resc_`p' asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_provandalize_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' asb_procuss_resc_`p'), missing
					la var asb_`p' "AntiSocial Behavior Index (0-27) Add Index of 9 questions"

				bysort phase round: summ asb_`p'

			* Create versions of the index that only include high/low emphasis components
				egen asb_g1_`p' = rowtotal(asb_reactlose_resc_`p' asb_reacthit_resc_`p' asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' asb_procuss_resc_`p'), missing
					la var asb_g1_`p' "AntiSocial Behavior Index, emphasis greater than 1" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen asb_le1_`p' = rowtotal(asb_provandalize_resc_`p'), m
					la var asb_le1_`p' "AntiSocial Behavior Index, emphasis less than or equal to 1" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen asb_g15_`p' = rowtotal(asb_reactlose_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_procuss_resc_`p'), missing
					la var asb_g15_`p' "AntiSocial Behavior Index, emphasis greater than 1.5" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen asb_le15_`p' = rowtotal(asb_reactdefend_resc_`p' asb_reacthit_resc_`p' asb_procompetitor_resc_`p' asb_provandalize_resc_`p' asb_prophysforce_resc_`p'), m
					la var asb_le15_`p' "AntiSocial Behavior Index, emphasis less than or equal to 1.5" /// See "variable construction/CBT Training Emphasis.xlsx"

				gen asb_g2_`p' = .
					la var asb_g2_`p' "AntiSocial Behavior Index, emphasis greater than 2" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen asb_le2_`p' = rowtotal(asb_reactdefend_resc_`p' asb_reacthit_resc_`p' asb_procompetitor_resc_`p' asb_provandalize_resc_`p' asb_prophysforce_resc_`p' asb_reactlose_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' asb_procuss_resc_`p'), m
					la var asb_le2_`p' "AntiSocial Behavior Index, emphasis less than or equal to 2" /// See "variable construction/CBT Training Emphasis.xlsx"

			}

		// HOSTILE BEHAVIORS (from psychosocial questions) (all surveys)

		foreach p in b e {

			* Variables for p1_e3wks, p2_e2wks, p3_e2w
				sum badreact_`p' badadvice_`p' hardjokes_`p' cheat_`p' troublesome_`p' frustrated_`p' threaten_`p' takethings_`p' selfdiscipline_`p'
				tab1 badreact_`p' badadvice_`p' hardjokes_`p' cheat_`p' troublesome_`p' frustrated_`p' threaten_`p' takethings_`p' selfdiscipline_`p'
			* Negative questions: Change to 0-Never, 1-One one time, 2-Sometimes, 3-Everytime

				foreach x in badreact badadvice hardjokes cheat troublesome frustrated threaten takethings baddestroy {
					gen `x'_resc_`p' = `x'_`p'*-1 + 4
						local lab: var lab `x'_`p'
						la var `x'_resc_`p' "Rescaled: `lab'"
				}

			* Positive questions: Change to 0-Everytime, 1-Sometimes, 2-One one time, 3-Never
				foreach x in selfdiscipline {
					gen `x'_resc_`p' = `x'_`p'-1
						local lab: var lab `x'_`p'
						la var `x'_resc_`p' "Rescaled: `lab'"
				}

			* Analyze responses
				summ badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' cheat_resc_`p' baddestroy_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'
				pwcorr badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' cheat_resc_`p' baddestroy_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'
				factor badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' cheat_resc_`p' baddestroy_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'

			* Generate declared hostility index
				egen hostility_`p' = rowtotal(badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' baddestroy_resc_`p' cheat_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'), m
					la var hostility_`p' "Hostile Behavior Index (0-30) Additive Index of 10 Survey Questions from the psychological section"

				bysort phase round: summ hostility_`p'

			* Create versions of the index that only include high/low emphasis components
				egen hostility_g1_`p' = rowtotal(badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' cheat_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'), m
					la var hostility_g1_`p' "Hostility Index, emphasis greater than 1" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen hostility_le1_`p' = rowtotal(baddestroy_resc_`p'), m
					la var hostility_le1_`p' "Hostility Index, emphasis less than or equal to 1" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen hostility_g15_`p' = rowtotal(badreact_resc_`p' badadvice_resc_`p' cheat_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'), m
					la var hostility_g15_`p' "Hostility Index, emphasis greater than 1.5" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen hostility_le15_`p' = rowtotal(baddestroy_resc_`p' hardjokes_resc_`p'), m
					la var hostility_le15_`p' "Hostility Index, emphasis less than or equal to 1.5" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen hostility_g2_`p' = rowtotal(badreact_resc_`p' troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' selfdiscipline_resc_`p'), m
					la var hostility_g2_`p' "Hostility Index, emphasis greater than 2" /// See "variable construction/CBT Training Emphasis.xlsx"

				egen hostility_le2_`p' = rowtotal(baddestroy_resc_`p' hardjokes_resc_`p' badadvice_resc_`p' cheat_resc_`p'), m
					la var hostility_le2_`p' "Hostility Index, emphasis less than or equal to 2" /// See "variable construction/CBT Training Emphasis.xlsx"

			}

		/* Hostility should be missing for round 2 */
		replace hostility_e = . if round == 2
		foreach x in g1 le1 g15 le15 g2 le2 {
			replace hostility_`x'_e = . if round == 2
		}

		/* Combine Barrett ASB and hostility indices */
		foreach p in b e {
			foreach x in badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' baddestroy_resc_`p' cheat_resc_`p' 		///
								troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' 				///
								selfdiscipline_resc_`p' asb_reactlose_resc_`p' asb_reacthit_resc_`p' 						///
								asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' 						///
								asb_provandalize_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' 				///
								asb_procuss_resc_`p' {



					if ("`p'" == "b") qui sum `x' if round == 1, d
					if ("`p'" == "b") qui gen Z_`x' = (`x'-r(mean))/r(sd)



					if ("`p'" == "e") {

			gen Z_p_`x'    = .
			gen Z_ss_`x'   = .
			gen Z_k_`x'    = .


			qui sum `x' , d
			qui replace Z_p_`x'  = (`x' - r(mean)) / r(sd)
			qui replace Z_k_`x' =  (`x' - r(mean)) / r(sd) if round >= 7


			qui sum `x' if round <= 6 , d
			qui replace Z_ss_`x'     = (`x' - r(mean)) / r(sd) if round <= 6
			qui replace Z_k_`x'     = (`x' - r(mean)) / r(sd)  if round <= 6


			qui sum `x' if round >=7 , d
			qui replace Z_ss_`x'     = (`x' - r(mean)) / r(sd) if round >= 7


					}


			}


								if ("`p'" == "b") {

			egen asbhostil_`p'    = rowtotal(Z_*), m
			qui sum asbhostil_`p' if round == 1, d
			qui replace asbhostil_`p' = (asbhostil_`p' - r(mean))/r(sd)

							}


								if ("`p'" == "e") {

			egen asbhostil_p_`p'       = rowtotal(Z_p_*), m
			egen asbhostil_ss_`p'       = rowtotal(Z_ss_*), m
			egen asbhostil_k_`p'       = rowtotal(Z_k_*), m


*pooled
			qui sum asbhostil_p_`p' , d
			qui gen asbhostil_z_p_`p' = (asbhostil_p_`p' - r(mean)) / r(sd)

*Split r78
			qui sum asbhostil_ss_`p' if round <= 6, d
			qui gen asbhostil_z_ss_`p'     = (asbhostil_ss_`p' - r(mean)) / r(sd) if round <= 6

			qui sum     asbhostil_ss_`p' if round >= 7, d
			qui replace asbhostil_z_ss_`p' = (asbhostil_ss_`p' - r(mean)) / r(sd) if round >= 7

*Known so far
			qui sum asbhostil_k_`p'  if round <= 6 , d
			qui gen asbhostil_z_k_`p' = (asbhostil_k_`p' - r(mean)) / r(sd) if round <= 6


			qui sum asbhostil_k_`p' , d
			qui replace asbhostil_z_k_`p' = (asbhostil_k_`p' - r(mean)) / r(sd) if round >= 7


													}

			drop Z_*

			* Create for
			egen asbhostil1_`p' = rowtotal(badreact_resc_`p' badadvice_resc_`p' hardjokes_resc_`p' baddestroy_resc_`p' cheat_resc_`p' 		///
								troublesome_resc_`p' frustrated_resc_`p' threaten_resc_`p' takethings_resc_`p' 				///
								selfdiscipline_resc_`p' asb_reactlose_resc_`p' asb_reacthit_resc_`p' 						///
								asb_reactdefend_resc_`p' asb_reacttease_resc_`p' asb_proontop_resc_`p' 						///
								asb_provandalize_resc_`p' asb_procompetitor_resc_`p' asb_prophysforce_resc_`p' 				///
								asb_procuss_resc_`p'),m
		}


				la var asbhostil_b          "Antisocial behavior index (Barrett ASB and Hostility, z 19 standardized components)"
				la var asbhostil_z_p_e   "Antisocial behavior index (Barrett ASB and Hostility, z 19 standardized components)"
				la var asbhostil_z_ss_e "Antisocial behavior index (Barrett ASB and Hostility, z 19 standardized components)"
				la var asbhostil_z_k_e  "Antisocial behavior index (Barrett ASB and Hostility, z 19 standardized components)"
